﻿using System;
using System.Web;
using System.Web.Script.Serialization;
using Easy.Operation;

namespace Easy.Web.Service.Entity
{
    /// <summary>
    /// AddReletion 的摘要说明
    /// </summary>
    public class AddReletion : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string json = context.Request["addReletion"];


            ResultClass rc = new ResultClass();

            try
            {

                JavaScriptSerializer jss = new JavaScriptSerializer();

                AddRelationClass bu = jss.Deserialize<AddRelationClass>(json);


                string saved_guid = EntitySetting_Function.AddRelation(bu);

                rc.Result = 0;
                rc.Remark = saved_guid;

            }

            catch (Exception e)
            {
                rc.Result = 1;
                rc.Remark = e.Message;
            }


            context.Response.Write(rc.ToJson());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}